package com.haiyou.dc.thread;

/**
 * lambda推导
 */
//1静态内部类
//2、局部内部类
//3、匿名内部类
//4、lambda简化
public class TestLambdaThread {

    static class Test1 implements Runnable {
        @Override
        public void run() {
            for (int i = 0; i < 20; i++) {
                System.out.println("测试......");
            }
        }
    }

    public static void main(String[] args) {
        //1静态内部类
        new Thread(new Test1()).start();

        class Test2 implements Runnable {
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println("测试......");
                }
            }
        }

        //2、局部内部类
        new Thread(new Test2()).start();

        //3、匿名内部类，必须是接口或者父类
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println("测试......");
                }
            }
        }).start();

        //4、lambda简化，只能是一个方法
        new Thread(() -> {
            for (int i = 0; i < 20; i++) {
                System.out.println("测试......");
            }
        }).start();
    }

}
